{include file="public/head"/} 
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">设备管理中心</a>
        <a><cite>门锁管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
      </div>
      <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加门锁','{:url('lockAdd')}',550,550)"><i class="layui-icon"></i>添加门锁</button>
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>ID</th>
            <th>所属小区</th>

            <th>门锁名称</th>
            <th>序列号</th>
            <th>门锁状态</th>

            <th>添加时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {foreach $list as $lis}
          <tr>
            <td>{$lis.id}</td>
            <td>{$lis.name}</td>


            <td>{$lis.lockname}</td>
            <td>{$lis.serial}</td>
            <td>
              {if $lis.status == 1}
                  已上线
              {elseif $lis.status == 2}
                  未上线
              {/if}
            </td>
            <!-- <td></td> -->
            <td>{$lis.time}</td>
            <td class="td-manage">

                  <!--
                  <a title="编辑"  onclick="x_admin_show('编辑','{:url(\'admin/Lock/lockEdit\')}?id={$lis.id}',780,600)" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                  </a>-->
                  <a title="上线" onclick="lockUpper('{$lis.serial}', 'u{$lis.serial}')" href="javascript:;" id="u{$lis.serial}">
                    <i class="layui-icon">&#xe62f;</i>
                  </a>
                  <a title="下线" onclick="lockLower('{$lis.serial}', 'l{$lis.serial}')" href="javascript:;" id="l{$lis.serial}">
                    <i class="layui-icon">&#xe601;</i>
                  </a>
                  <a title="开门" onclick="openurl('{$lis.id}')">
                    <i class="layui-icon">&#xe628;</i>
                  </a>
                  <a title="删除" onclick="lockDel('{$lis.serial}', 'd{$lis.serial}')" href="javascript:;" id="d{$lis.serial}">
                    <i class="layui-icon">&#xe640;</i>
                  </a>

            </td>
          </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
          {$locklist->render()}
        </div>
      </div>

    </div>
    <script>
    function openurl(id){
        layer.open({
            type: 1,
            skin: 'x-right', //样式类名
            closeBtn: 0, //不显示关闭按钮
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            area: ['80%', '300px'],
            content:
            '<div style="padding: 20px 100px; font-size:18px">'+
            '扫码开门链接：https://www.zhwuye.zfbzhsq.com/api/lock/open?id='+ id + '<br><br>'+


            '</div>'
        });
    }
      //上线
      function lockUpper(serial, doc){
        if(confirm('确定要上线吗?')) 
        { 
          var url = "{:url('lockUpper')}?serial=" + serial
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 
      //开门
      function lockOpen(serial, doc){
        if(confirm('确定要开门吗?')) 
        { 
          var url = "{:url('lockOpen')}?serial=" + serial
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 
      //下线
      function lockLower(serial, doc){
        if(confirm('确定要下线吗?')) 
        { 
          var url = "{:url('lockLower')}?serial=" + serial
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      }
      //删除
      function lockDel(serial, doc){
        if(confirm('确定要删除吗?')) 
        { 
          var url = "{:url('lockDel')}?serial=" + serial
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  </body>

</html>